﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Printing.DataGridViewPrint.Tools;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Drawing;

namespace Riel_Gestion.printer
{
    class PrinterImpl
    {
        PrintingDataGridViewProvider printProvider = null;
        PrintDocument printerDocument = null;
        
        public PrinterImpl(DataGridView dgv, String titulo) 
        {            
            printerDocument = new PrintDocument();
            printerDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);

            printProvider = PrintingDataGridViewProvider.Create(
                printerDocument,
                dgv,
                true, true, true,
                new TitlePrintBlock(titulo + "\n\n", Color.DarkGray, new Font("Arial", 10)),
                new ReportHeader(),
                new ReportFooter()
                );         
            
        }

        public PrintingDataGridViewProvider getPrintProvider()
        {
            return printProvider;
        }

        public PrintDocument getDocument()
        {
            return printerDocument;
        }

        public void print()
        {
            printerDocument.Print();
        }

    }
}
